import type * as BS from "./type"
import { request } from "@/http/axios"
// 获取组件模型列表
export function getModelList() {
  return request<BS.ModelResponse>({
    url: `/toksim/model/component/list`,
    method: "post"
  })
}
// 检索组件模型
export function getModelSearch(params?: BS.ModelSearchData) {
  return request<BS.ModelResponse>({
    url: `/toksim/model/component/search`,
    method: "post",
    data: params,
    params: {
      pageSize: params?.size,
      pageNum: params?.current_page
    }
  })
}
// 查询标签
export function searchClassifyApi(params?: BS.ModelSearchData) {
  return request({
    url: "/toksim/model/component/searchClassify",
    method: "post",
    data: params
  })
}

// 保存组件模型
export function saveModelField(params: BS.SaveRequestData) {
  return request({
    url: `/toksim/model/component/save`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data: params
  })
}

// 查询组件详细信息
export function getModelDetail(id: string) {
  return request<BS.ModelViewResData>({
    url: `/toksim/model/component/getComponentInfo/${id}`,
    method: "get"
  })
}

// 新增组件模型
export function saveModel(params: BS.ModelData) {
  return request<BS.ModelDetail>({
    url: `/toksim/model/component/save`,
    method: "post",
    data: params
  })
}
// 编辑组件模型
export function editModel(params: BS.SaveModelData) {
  return request<BS.ModelDetail>({
    url: `/toksim/model/component/edit`,
    method: "post",
    data: params
  })
}
// 删除组件模型
export function deleteModel(id: string) {
  return request<BS.ModelDetail>({
    url: `/toksim/model/component/delete/${id}`,
    method: "delete"
  })
}
// 批量删除组件模型
export function deleteModelBatch(ids: string[]) {
  return request<BS.ModelDetail>({
    url: `/toksim/model/component/batchDelete`,
    method: "delete",
    data: { ids }
  })
}

/** 上传实体附件 */
export function uploadEntityFilesApi(params: any) {
  return request({
    url: "/casia/model/entity/saveFiles",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data: params
  })
}